/*
 * Copyright (c) 2010 Sylvestre Gallon <syl@pmbsd.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef __DISPATCH_H__
#define __DISPATCH_H__

typedef struct objc_methods {
        SEL method_name;
        const char *method_types;
        IMP method_imp;
} *Method;

struct objc_method_list {
        struct objc_method_list *next;
        int nb_methods;
        struct objc_methods method_list[1];
};

struct objc_dispatch_elem {
        void *sel_id;
        IMP method_imp;
        TAILQ_ENTRY(objc_dispatch_elem) entry;
};

TAILQ_HEAD(objc_dispatch_list_head, objc_dispatch_elem);

struct objc_dispatch_list {
        struct objc_dispatch_list_head list;
};

IMP objc_msg_lookup_super(Super super, SEL op);
IMP objc_msg_lookup(id receiver, SEL op);
void __objc_init_dispatch_tables(void);
void __objc_install_premature_dtable(Class cl);
IMP __objc_get_from_dispatch(Class receiver, SEL op);
void __objc_install_dispatch_table_for_class(Class cl);
id nil_method(id receiver, SEL op);

#endif /*__DISPATCH_H__*/
